﻿using System;
using System.Collections.Generic;
using System.IO;

namespace CzfSDK
{
	public class ConfigManager
	{
		public static ConfigManager current;

		private Dictionary<string, Config> _configs = new Dictionary<string, Config>();
		public ConfigManager (string path)
		{
			current = this;

			var dir = new DirectoryInfo (path);
			foreach (var file in dir.GetFiles("*.json")) {
				using (var sr = new StreamReader (file.OpenRead ())) {
					_configs [file.Name.CzfTrimEnd(".json")] = new Config(sr);
					sr.Close ();
				}
			}
		}

		public Config this[string name] {
			get{
				if (_configs.ContainsKey (name))
					return _configs [name];
				else
					return null;
			}
		}

		public void Debug()
		{
			CzfLog.Info (_configs);
		}
	}
}

